As network technologies continuously develop, software-defined networking (SDN) appears, where an OpenFlow (OF) protocol is a typical technology of the SDN. Network elements of the OF protocol include an OF controller (controller) and an OF switch (switch), where the OF controller is called a controller for short, and the OF switch is called a switch for short. The controller determines, according to features of a packet such as a 5-tuple, an Ethernet frame header, and a virtual local area network (VLAN) identifier (ID), a forwarding action of a service flow such as forwarding, discarding, modifying a packet header, encapsulating, or decapsulating, and sends, to the switch, a flow rule corresponding to the service flow and one or more actions to be correspondingly performed. The switch receives and stores the flow rule sent by the controller, and performs an action corresponding to the flow rule on a subsequent packet that complies with the flow rule, so as to implement packet forwarding or processing.
First, the controller sends the flow rule to the switch by using a modify flow entry message (Flow_Mod). The flow rule includes a flow match rule and a corresponding processing action. The flow match rule may include a combination of information such as the Ethernet frame header, Internet Protocol (IP) header information, or a Transmission Control Protocol (TCP)/User Datagram Protocol (UDP) port number. The processing action includes a processing type and a related parameter, where the processing type is, for example, forwarding, discarding, modifying, encapsulating, or decapsulating. The controller may send flow match rules of different flow tables (flow table) to the switch by using multiple modify flow entry messages. Then, the switch stores or installs, in a flow table, all flow match rules and corresponding processing actions that are received from the controller. Finally, when the switch receives a packet sent by a user, the switch performs flow table matching, and processes, according to an action set corresponding to a matching flow rule, the packet sent by the user.
The OF protocol may implement adding, modifying, or deleting of a flow rule by using a modify flow entry message. However, the controller can complete modifying a flow entry only by using an action of adding or deleting a flow table entry. For example, two modify flow entry messages need to be sent for modifying a flow entry of a MAC address and an IP address. First, the controller sends, to the switch, a modify flow entry message that carries a deleting instruction to delete the flow entry, where a match field carries (a source IP address that is equal to IP2 and a source MAC address that is equal to MAC2). Then, the controller sends, to the switch, a modify flow entry message that carries an adding instruction to add a new flow entry, where a match field in the new flow entry carries (a source IP address that is equal to IP3 and a source MAC address that is equal to MAC3). To modify N flow entries, the controller needs to send 2N modify flow entry messages to the switch, where each modify flow entry message carries a complete match (match) or action (action) field.
In conclusion, a general method for modifying a flow table has disadvantages of information redundancy, low efficiency, and an overloaded interface.